package com.atguigu.springboot.controller;

import com.atguigu.springboot.config.AtguiguConfig;
import com.atguigu.springboot.service.RobotService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DemoController {

    @Resource
    private AtguiguConfig atguiguConfig;

    @Value("${atguigu.message}")
    private String message;

    @Resource
    private RobotService robotService;

    @GetMapping("/say/hello/to/spring/boot")
    public String hello() {

        String schoolName = atguiguConfig.getSchoolName();
        System.out.println("schoolName = " + schoolName);

        Integer schoolAge = atguiguConfig.getSchoolAge();
        System.out.println("schoolAge = " + schoolAge);

        List<String> schoolSubject = atguiguConfig.getSchoolSubject();
        for (String subject : schoolSubject) {
            System.out.println("subject = " + subject);
        }

        System.out.println("message = " + message);

        return "Hello!SpringBoot!~~~~~~~~";
    }

    @GetMapping("/test/robot")
    public String testRobot() {
        return robotService.sayHello();
    }
}
